package com.befiv.lock.redis;

import com.befiv.lock.redis.exception.UnableToAquireLockException;

/**
 * 获取锁管理类
 * @Author: Gjq
 * @Date: 2019/3/25 0025 下午 5:37
 */
public interface DistributedLocker<T> {
    /**
     * 获取锁
     * @param resourceName  锁的名称
     * @param worker 获取锁后的处理类
     * @param <T>
     * @return 处理完具体的业务逻辑要返回的数据
     * @throws UnableToAquireLockException
     * @throws Exception
     */
    <T> T lock(String resourceName, AquiredLockWorker<T> worker) throws UnableToAquireLockException, Exception;

    <T> T lock(String resourceName, AquiredLockWorker<T> worker, long lockTime,long timeout) throws Exception;
}
